//package com.douqu.game.main.platform;
//
//import com.alibaba.fastjson.JSONObject;
//import com.bean.core.util.HttpStringUtil;
//import com.douqu.game.core.database.model.UserModel;
//import com.douqu.game.core.factory.ConstantFactory;
//import com.douqu.game.core.factory.PlatformFactory;
//import com.douqu.game.core.protobuf.SGCommonProto;
//import com.douqu.game.core.util.CoreUtils;
//import com.douqu.game.core.util.LogUtils;
//import com.douqu.game.main.service.PlayerService;
//import com.douqu.game.main.util.DesUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import sun.security.krb5.internal.crypto.Des;
//
//import java.text.MessageFormat;
//
///**
// * Created by dengbo on 2018/9/12 0012.
// */
//@Component
//public class JTImpl implements PlatformSDK{
//
//    @Autowired
//    private PlayerService playerService;
//
//    @Override
//    public UserModel login(String account, String password) {
//        LogUtils.info("即拓登录参数:" + account + "  " + password);
//        String [] param = password.split(ConstantFactory.DIVISION);
//        //版本号默认为1.0
//        String version;
//        //商户名简写
//        String componentCode;
//        //时间戳
//        String timeStamp ;
//        String token ;
//        try {
//            version = param[0];
//            componentCode = param[1];
//            timeStamp = param[2];
//            token = param[3];
//        } catch (Exception e) {
//            e.printStackTrace();
//            LogUtils.error("参数解析错误:" + password);
//            return new UserModel();
//        }
//        //认证编号
//        String authenticateCode=version+"|"+componentCode+"|"+timeStamp;
//        //加密
//        String authenticateCodes= DesUtils.encrypt(authenticateCode, PlatformFactory.JT_AKEY);
//        String url = MessageFormat.format(PlatformFactory.JT_CHECK_LOGIN_URL, version, componentCode, timeStamp, authenticateCodes, token);
//        LogUtils.info("即拓url:" + url );
//        String str = HttpStringUtil.sendHttpGet(url);
//        LogUtils.info("即拓str:" + str );
//        JSONObject result = JSONObject.parseObject(str);
//        JSONObject object;
//        //里面包含userId
//        JSONObject data ;
//        String resultCode;
//        String resultMsg;
//        try {
//            object =result.getJSONObject("result");
//            resultCode = object.getString("resultCode");
//            resultMsg = object.getString("resultMsg");
//            data =result.getJSONObject("data");
//            LogUtils.info("即拓返回值:resultCode:" + resultCode + " resultMsg: " + resultMsg + "data: " +data);
//        }catch (Exception e){
//            LogUtils.error("即拓获取数据失败:" + account);
//            e.printStackTrace();
//            return new UserModel();
//        }
//        if(!resultCode.equals("000000")||!resultMsg.equals("成功") ||data==null){
//            LogUtils.error("即拓验证失败:" + account);
//            return new UserModel();
//        }
//        //TODO userid =account???
//        String userId = data.getString("userid");
//        account = CoreUtils.createAccount(userId, SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_JITUO);
//        UserModel player = playerService.getUserByAccount(account);
//        return player;
//    }
//
//    public static void main(String[] args) {
//        String str ="{\"data\":\"\",\"result\":{\"resultCode\":\"539999\",\"resultMsg\":\"请求参数错误\"}}";
//        JSONObject result = JSONObject.parseObject(str);
//        JSONObject object =result.getJSONObject("result");
//        JSONObject data =result.getJSONObject("data");
//        if (data == null){
//            System.out.println("data....:"+data);
//        }
//        String resultCode=object.getString("resultCode");
//        String resultMsg=object.getString("resultMsg");
//        System.out.println(data+"..."+resultCode+"..."+resultMsg);
//        str ="1.0|comp|2017010101020202";
//        str=DesUtils.encrypt(str, "gNetopSZ");
//        System.out.println("加密后....:"+str);
//
//    }
//}
